package com.mitdy.sg.data.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.mitdy.sg.common.bean.Pagination;
import com.mitdy.sg.data.entity.BasketballGameEvent;
import com.mitdy.sg.data.mapper.BasketballGameEventMapper;
import com.mitdy.sg.data.vo.BasketballGameEventVO;

@Service
public class BasketballGameEventService {

	@Autowired
	private BasketballGameEventMapper basketballGameEventMapper;

	public PageInfo<BasketballGameEventVO> getBasketballGameEventPageInfo(BasketballGameEventVO basketballGameEvent, Pagination pagination) {
		Page<BasketballGameEventVO> page = PageHelper.startPage(pagination.getPage(), pagination.getRows());
		basketballGameEventMapper.getPageInfo(basketballGameEvent);
		PageInfo<BasketballGameEventVO> pageInfo = new PageInfo<BasketballGameEventVO>(page);
		return pageInfo;
	}
	
	public BasketballGameEventVO getBasketballGameEventById(Long basketballGameEventId) {
		return basketballGameEventMapper.getBasketballGameEventById(basketballGameEventId);
	}
	
	public PageInfo<BasketballGameEventVO> getGameEventView(BasketballGameEventVO basketballGameEvent, Pagination pagination) {
	    Page<BasketballGameEventVO> page = PageHelper.startPage(pagination.getPage(), pagination.getRows());
	    basketballGameEventMapper.getGameEventView(basketballGameEvent);
	    PageInfo<BasketballGameEventVO> pageInfo = new PageInfo<BasketballGameEventVO>(page);
        return pageInfo;
	}

	public BasketballGameEventVO getBasketballGameEventByGameIdAndDate(BasketballGameEvent basketballGameEventVO) {
	    return basketballGameEventMapper.getBasketballGameEventByGameIdAndDate(basketballGameEventVO);
	}
	
	@Transactional
	public BasketballGameEventVO addBasketballGameEvent(BasketballGameEventVO basketballGameEvent) {
		basketballGameEventMapper.insert(basketballGameEvent);
		return basketballGameEvent;
	}

    @Transactional
	public BasketballGameEventVO updateBasketballGameEvent(BasketballGameEventVO basketballGameEvent) {
		basketballGameEventMapper.updateByPrimaryKeySelective(basketballGameEvent);
		return basketballGameEvent;
	}

	@Transactional
	public void deleteBasketballGameEventById(Long basketballGameEventId) {
		basketballGameEventMapper.deleteByPrimaryKey(basketballGameEventId);
	}

}